{
const GskColorStop *stops = gsk_conic_gradient_node_get_color_stops (node, NULL);
const graphene_point_t *center = gsk_conic_gradient_node_get_center (node);
- const float rotation = gsk_conic_gradient_node_get_rotation (node);
+ const float angle = gsk_conic_gradient_node_get_angle (node);
ops_set_program (builder, &self->programs->conic_gradient_program);
ops_set_conic_gradient (builder,
stops,
builder->dx + center->x,
builder->dy + center->y,
- rotation);
+ angle);
load_vertex_data (ops_draw (builder, NULL), &node->bounds, builder);
}
apply_conic_gradient_op (const Program *program,
const OpConicGradient *op)
{
- float angle;
float bias;
float scale;
op->n_color_stops.value * 5,
(float *)op->color_stops.value);
- angle = 90.0f - op->rotation;
- angle = M_PI * angle / 180.0f;
- angle = fmodf (angle, 2.0f * M_PI);
- if (angle < 0.0f)
- angle += 2.0f * M_PI;
-
scale = 0.5f * M_1_PI;
- bias = angle * scale + 2.0f;
+ bias = op->angle * scale + 2.0f;
glUniform4f (program->conic_gradient.geometry_location, op->center[0], op->center[1], scale, bias);
}
const GskColorStop *color_stops,
float center_x,
float center_y,
- float rotation)
+ float angle)
{
const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
OpConicGradient *op;
op->color_stops.send = true;
op->center[0] = center_x;
op->center[1] = center_y;
- op->rotation = rotation;
+ op->angle = angle;
}
const GskColorStop *color_stops,
float center_x,
float center_y,
- float rotation);
+ float angle);
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
const GskQuadVertex vertex_data[GL_N_VERTICES]);
ColorStopUniformValue color_stops;
IntUniformValue n_color_stops;
float center[2];
- float rotation;
+ float angle;
} OpConicGradient;
typedef struct
GDK_AVAILABLE_IN_ALL
float gsk_conic_gradient_node_get_rotation (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
+float gsk_conic_gradient_node_get_angle (GskRenderNode *node);
+GDK_AVAILABLE_IN_ALL
gsize gsk_conic_gradient_node_get_n_color_stops (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
const GskColorStop * gsk_conic_gradient_node_get_color_stops (GskRenderNode *node,
graphene_point_t center;
float rotation;
+ float angle;
gsize n_stops;
GskColorStop *stops;
self->stops = g_malloc_n (n_color_stops, sizeof (GskColorStop));
memcpy (self->stops, color_stops, n_color_stops * sizeof (GskColorStop));
+ self->angle = 90.f - self->rotation;
+ self->angle = G_PI * self->angle / 180.f;
+ self->angle = fmodf (self->angle, 2.f * G_PI);
+ if (self->angle < 0.f)
+ self->angle += 2.f * G_PI;
+
return node;
}
return self->rotation;
}
+/**
+ * gsk_conic_gradient_node_get_angle:
+ * @node: (type GskConicGradientNode): a #GskRenderNode for a conic gradient
+ *
+ * Retrieves the angle for the gradient in radians, normalized in [0, 2 * PI]
+ *
+ * The angle is starting at the top and going clockwise, as expressed
+ * in the css specification:
+ * angle = 90 - gsk_conic_gradient_node_get_rotation()
+ *
+ * Returns: the angle for the gradient
+ */
+float
+gsk_conic_gradient_node_get_angle (GskRenderNode *node)
+{
+ GskConicGradientNode *self = (GskConicGradientNode *) node;
+
+ return self->angle;
+}
+
/*** GSK_BORDER_NODE ***/
/**